package com.belazy.auto.configure;

import com.belazy.auto.configure.properties.AliyunOrcProperties;
import com.belazy.auto.configure.service.IOrcService;
import com.belazy.auto.configure.service.impl.AliyunOrcService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnClass(IOrcService.class)
@EnableConfigurationProperties(AliyunOrcProperties.class)
public class OrcConfiguration {
    private final AliyunOrcProperties aliyunOrcProperties;
    public OrcConfiguration(AliyunOrcProperties properties) {
        this.aliyunOrcProperties = properties;
    }

    @Bean
    @ConditionalOnMissingBean(IOrcService.class)
    @ConditionalOnProperty(prefix = "ocr.aliyun", value = "enabled", havingValue = "true")
    public IOrcService iAliyunOrcService() {
        return new AliyunOrcService (aliyunOrcProperties);
    }
}
